home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 159_01 / advent.h < prev    next >
C/C++ Source or Header  |  1990-05-03  |  14KB  |  463 lines

  1.  
  2. /*    ADVENT.H    revised header for BDS c vers 1.43   */
  3.  
  4. /*                Revised for Eco-C88 V2.72 by Bob Withers
  5.                   Defined all variables for driver routines and
  6.                   altered header to declare them external for
  7.                   all sub-modules.    BW - 09/14/85
  8. */
  9.  
  10. #define NUL                '\0'
  11.  
  12. #define MAXDIM(a)            (sizeof(a) / sizeof(a[0]))
  13.  
  14. #define VOID                void
  15. #define NEAR                near
  16. #define PASCAL                pascal
  17.  
  18. #ifndef TRUE
  19. #define TRUE                1
  20. #define FALSE                0
  21. #endif
  22.  
  23. typedef short                SHORT;
  24. typedef unsigned short            USHORT;
  25. typedef long                LONG;
  26. typedef unsigned long            ULONG;
  27. typedef short                BOOL;
  28.  
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <ctype.h>
  32. #include <string.h>
  33.  
  34. #define MAXLOC                150
  35. #define MAXOBJ                100
  36. #define WORDSIZE            20
  37.  
  38. #define DWARFMAX            7
  39. #define MAXDIE                3
  40. #define MAXTRS                79
  41.  
  42. #define READ_BIN            "rb"
  43. #define WRITE_BIN            "wb"
  44.  
  45.  
  46. #define VOCAB_OBJECT            1000
  47. #define VOCAB_VERB            2000
  48. #define VOCAB_MSG            3000
  49.  
  50. /*
  51.         Object definitions
  52. */
  53. #define KEYS                1
  54. #define LAMP                2
  55. #define GRATE                3
  56. #define CAGE                4
  57. #define ROD                5
  58. #define ROD2                6
  59. #define STEPS                7
  60. #define BIRD                8
  61. #define DOOR                9
  62. #define PILLOW                10
  63. #define SNAKE                11
  64. #define FISSURE             12
  65. #define TABLET                13
  66. #define CLAM                14
  67. #define OYSTER                15
  68. #define MAGAZINE            16
  69. #define DWARF                17
  70. #define KNIFE                18
  71. #define FOOD                19
  72. #define BOTTLE                20
  73. #define WATER                21
  74. #define OIL                22
  75. #define MIRROR                23
  76. #define PLANT                24
  77. #define PLANT2                25
  78. #define STALACTITE            26
  79. #define FIGURE                27
  80. #define AXE                28
  81. #define DRAWING             29
  82. #define PIRATE                30
  83. #define DRAGON                31
  84. #define CHASM                32
  85. #define TROLL                33
  86. #define TROLL2                34
  87. #define BEAR                35
  88. #define MESSAGE             36
  89. #define VOLCANO             37
  90. #define VEND                38
  91. #define BATTERIES            39
  92. #define CARPET                40
  93. #define NUGGET                50
  94. #define DIAMONDS            51
  95. #define SILVER                52
  96. #define JEWELS                53
  97. #define COINS                54
  98. #define CHEST                55
  99. #define EGGS                56
  100. #define TRIDENT             57
  101. #define VASE                58
  102. #define EMERALD             59
  103. #define PYRAMID             60
  104. #define PEARL                61
  105. #define RUG                62
  106. #define SPICES                63
  107. #define CHAIN                64
  108.  
  109. /*
  110.         Verb definitions
  111. */
  112. #define NULLX                21
  113. #define BACK                8
  114. #define LOOK                57
  115. #define CAVE                67
  116. #define ENTRANCE            64
  117. #define DEPRESSION            63
  118.  
  119. /*
  120.         Action verb definitions
  121. */
  122. #define TAKE                1
  123. #define DROP                2
  124. #define SAY                3
  125. #define OPEN                4
  126. #define NOTHING             5
  127. #define LOCK                6
  128. #define ON                7
  129. #define OFF                8
  130. #define WAVE                9
  131. #define CALM                10
  132. #define WALK                11
  133. #define KILL                12
  134. #define POUR                13
  135. #define EAT                14
  136. #define DRINK                15
  137. #define RUB                16
  138. #define THROW                17
  139. #define QUIT                18
  140. #define FIND                19
  141. #define INVENTORY            20
  142. #define FEED                21
  143. #define FILL                22
  144. #define BLAST                23
  145. #define SCORE                24
  146. #define FOO                25
  147. #define BRIEF                26
  148. #define READ                27
  149. #define BREAK                28
  150. #define WAKE                29
  151. #define SUSPEND             30
  152. #define HOURS                31
  153. #define LOG                32
  154. #define SAVE                33
  155. #define RESTORE             34
  156. #define VERBOSE             35
  157.  
  158. /*
  159.         Bits of array cond
  160.         indicating location status
  161. */
  162. #define LIGHT                1
  163. #define WATOIL                2
  164. #define LIQUID                4
  165. #define NOPIRAT             8
  166. #define HINTC                16
  167. #define HINTB                32
  168. #define HINTS                64
  169. #define HINTM                128
  170. #define HINT                240
  171.  
  172. /*
  173.         Adventure global variables
  174. */
  175.  
  176. struct S_VocabTab
  177. {
  178.     char    *pWord;
  179.     SHORT     sWord;
  180. };
  181. typedef struct S_VocabTab        VOCABTAB;
  182.  
  183. struct trav
  184. {
  185.     SHORT     tdest;
  186.     SHORT     tverb;
  187.     SHORT     tcond;
  188. };
  189. typedef struct trav            TRAV;
  190.  
  191. struct travtab
  192. {
  193.     TRAV    *pTrav;             // trav array for location
  194.     SHORT     sTrav;             // # entries for location
  195. };
  196. typedef struct travtab            TRAVTAB;
  197.  
  198.  
  199. #ifdef DRIVER
  200. #define CLASS
  201. #define INIT(x)         = x
  202. #else
  203. #define CLASS            extern
  204. #define INIT(x)
  205. #endif
  206.  
  207. #define NEARDATA        NEAR
  208.  
  209. CLASS SHORT  brief_sw;
  210. /*
  211.         Database variables
  212. */
  213. CLASS TRAV *     NEARDATA pTravel;        /* travel array & count for */
  214. CLASS SHORT     NEARDATA sTravCnt;        /* the current location     */
  215. CLASS SHORT     NEARDATA actmsg[32]              /* action messages */
  216. #ifdef DRIVER
  217.       = {
  218.           0,  24,  29,   0,  33,   0,  33,    38,  38,  42,  /*  0 -    9 */
  219.          14,  43, 110,  29, 110,  73,  75,    29,  13,  59,  /* 10 - 19 */
  220.          59, 174, 109,  67,  13, 147, 155, 195, 146, 110,  /* 20 - 29 */
  221.          13,  13                           /* 30 - 31 */
  222.     };
  223. #else
  224.      ;
  225. #endif
  226.  
  227. /*
  228.         English variables
  229. */
  230. CLASS SHORT     NEARDATA verb;
  231. CLASS SHORT     NEARDATA object;
  232. CLASS SHORT     NEARDATA motion;
  233. CLASS char     NEARDATA word1[WORDSIZE];
  234. CLASS char     NEARDATA word2[WORDSIZE];
  235.  
  236. /*
  237.         Play variables
  238. */
  239. CLASS SHORT     NEARDATA turns        INIT(0);
  240. CLASS SHORT     NEARDATA loc           INIT(1);
  241. CLASS SHORT     NEARDATA oldloc       INIT(1);
  242. CLASS SHORT     NEARDATA oldloc2       INIT(1);
  243. CLASS SHORT     NEARDATA newloc       INIT(3);
  244. CLASS SHORT     NEARDATA cond[MAXLOC]             /* location status    */
  245. #ifdef DRIVER
  246.       = {
  247.           0,   5,    1,   5,   5,   1,   1,     5,  17,   1,  /*   0 -   9 */
  248.           1,   0,    0,  32,   0,   0,   2,     0,   0,  64,  /*  10 -  19 */
  249.           2,   2,    2,   0,   6,   0,   2,     0,   0,   0,  /*  20 -  29 */
  250.           0,   2,    2,   0,   0,   0,   0,     0,   4,   0,  /*  30 -  39 */
  251.           2,   0, 128, 128, 128, 128, 136, 136, 136, 128,  /*  40 -  49 */
  252.         128, 128, 128, 136, 128, 136,   0,     8,   0,   2,  /*  50 -  59 */
  253.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /*  60 -  69 */
  254.           0,   0,    0,   0,   0,   0,   0,     0,   0,   2,  /*  70 -  79 */
  255.         128, 128, 136,   0,   0,   8, 136, 128,   0,   2,  /*  80 -  89 */
  256.           2,   0,    0,   0,   0,   4,   0,     0,   0,   0,  /*  90 -  99 */
  257.           1,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 100 - 109 */
  258.           0,   0,    0,   4,   0,   1,   1,     0,   0,   0,  /* 110 - 119 */
  259.           0,   0,    8,   8,   8,   8,   8,     8,   8,   8,  /* 120 - 129 */
  260.           8,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 130 - 139 */
  261.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 140 - 149 */
  262.     };
  263. #else
  264.      ;
  265. #endif
  266.  
  267. CLASS SHORT     NEARDATA place[MAXOBJ]           /* object location    */
  268. #ifdef DRIVER
  269.       = {
  270.           0,   3,    3,   8,  10,  11,   0,    14,  13,  94,  /*  0 -    9 */
  271.          96,  19,  17, 101, 103,   0, 106,     0,   0,   3,  /* 10 - 19 */
  272.           3,   0,    0, 109,  25,  23, 111,    35,   0,  97,  /* 20 - 29 */
  273.           0, 119, 117, 117,   0, 130,   0, 126, 140,   0,  /* 30 - 39 */
  274.          96,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 40 - 49 */
  275.          18,  27,  28,  29,  30,   0,  92,    95,  97, 100,  /* 50 - 59 */
  276.         101,   0, 119, 127, 130,   0,   0,     0,   0,   0,  /* 60 - 69 */
  277.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 70 - 79 */
  278.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 80 - 89 */
  279.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 90 - 99 */
  280.     };
  281. #else
  282.      ;
  283. #endif
  284.  
  285. CLASS SHORT     NEARDATA fixed[MAXOBJ]           /* second object loc  */
  286. #ifdef DRIVER
  287.       = {
  288.           0,   0,    0,   9,   0,   0,   0,    15,   0,  -1,  /*  0 -    9 */
  289.           0,  -1,  27,  -1,   0,   0,   0,    -1,   0,   0,  /* 10 - 19 */
  290.           0,   0,    0,  -1,  -1,  67,  -1, 110,   0,  -1,  /* 20 - 29 */
  291.          -1, 121, 122, 122,   0,  -1,  -1,    -1,  -1,   0,  /* 30 - 39 */
  292.          -1,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 40 - 49 */
  293.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 50 - 59 */
  294.           0,   0, 121,   0,  -1,   0,   0,     0,   0,   0,  /* 60 - 69 */
  295.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 70 - 79 */
  296.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 80 - 89 */
  297.           0,   0,    0,   0,   0,   0,   0,     0,   0,   0,  /* 90 - 99 */
  298.     };
  299. #else
  300.      ;
  301. #endif
  302.  
  303. CLASS SHORT     NEARDATA visited[MAXLOC];         /* >0 i